package net.divbyzero.gpx.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;

import net.divbyzero.gpx.GPX;
import net.divbyzero.gpx.Track;
import net.divbyzero.gpx.TrackSegment;
import net.divbyzero.gpx.Waypoint;
import net.divbyzero.gpx.parser.JDOM;
import net.divbyzero.gpx.parser.Parser;
import net.divbyzero.gpx.parser.ParsingException;

public class FlowerTest {
	public static void main(String[] args) throws ParsingException {
		URL url = null;
		Parser parser = new JDOM();
		try {
			url = new File("data/Venezia.gpx").toURL();
		} catch (MalformedURLException e) {
			fail();
		}

		GPX gpx = parser.parse(url);
		System.out.println("num tracks: " + gpx.getTracks().size());
		for (Track track : gpx.getTracks()) {
			System.out.println(track.startingTime());
			System.out.println(track.endTime());
		}
		ArrayList<TrackSegment> seg = gpx.getTracks().get(0).getSegments();
		System.out.println(seg.size());
		for (TrackSegment trackSegment : seg) {
			System.out.println(trackSegment.getWaypoints().size());
			for (Waypoint way : trackSegment.getWaypoints()) {
				System.out.println("time: " + way.getTime());
				System.out.println("lat: " + way.getCoordinate().getLatitude());
				System.out.println("lon:" + way.getCoordinate().getLongitude());
				System.out.println("++++++++++++++++");

			}

		}

	}
}
